using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;

public class Orc : EnemyController
{
    public void Skill1Event()
    {
        var colliders = Physics.OverlapSphere(transform.position, characterStats.attackData.skill1Range);
        foreach(var target in colliders)
        {
            if (target.CompareTag("Player"))
            {
                attackTarget = target.gameObject;
            }
        }
        
        if (attackTarget!= null&& Vector3.Distance(transform.position,attackTarget.transform.position)<characterStats.attackData.skill1Range){
            var targetStats = attackTarget.GetComponent<CharacterStats>();
            targetStats.TakeDamage((int)characterStats.attackData.maxDamage*2, targetStats);
        }
    }

    public void PrepareForSkill2()
    {
        var colliders = Physics.OverlapSphere(transform.position, characterStats.attackData.skill2_1Range);
        foreach(var target in colliders)
        {
            if (target.CompareTag("Player"))
            {
                attackTarget = target.gameObject;
            }
        }

        transform.DOMove(attackTarget.transform.position, 0.75f);
    }

    public void Skill2Event()
    {
        var colliders = Physics.OverlapSphere(transform.position, characterStats.attackData.skill2_2Range);
        foreach(var target in colliders)
        {
            if (target.CompareTag("Player"))
            {
                attackTarget = target.gameObject;
            }
        }
        if (attackTarget!= null&& Vector3.Distance(transform.position,attackTarget.transform.position)<characterStats.attackData.skill2_2Range){
            var targetStats = attackTarget.GetComponent<CharacterStats>();
            targetStats.TakeDamage((int)characterStats.attackData.maxDamage, targetStats);
            attackTarget.GetComponent<Animator>().SetTrigger("Dazzy");
        }
    }
}
